<?php

class Order extends Controller {

    function __construct() {
        parent::__construct();
        //echo 'We are in order controll';
        $this->view->msg = 'This for order';
        $this->loadModel('order');
    }

    function index(){

        /*$data = $this->model->getData();
        if (isset($data['loggedIn']) && $data['loggedIn']){
            $this->view->assign('loggedIn', true);
            $this->view->assign('userName', $data['userName']);
            $this->view->render('index/loginSuccess');

        }else{
            $this->view->render('index/index');
        }*/
        if (Session::get('loggedIn')){

            $data = $this->model->getData();
            if($data['view'] == 'index'){
                $tplVars = array('userList', 'msg', 'nextOrderId', 'list');
                $tplVars = array_merge($tplVars,Database::$orderFieldSet);
                foreach($tplVars AS $val ){
                    $this->view->assign($val, $data[$val]);
                }


                $this->view->render('order/index');
            }else if($data['view'] == 'detail'){

                $tplVars = array('userList','msg', 'ean', 'orderId', 'article_id','count','supplier','price_e','listArticle','einkauflist');
                foreach($tplVars AS $val ){
                    $this->view->assign($val, $data[$val]);
                }
                //var_dump($this->view->_tpl_vars);

                $this->view->render('order/detail');
            }else if($data['view'] == 'detail'){

            }
        }else{
            header('Location: ./index.php');
        }

    }

    public function getRunTimeJessiMsg(){

        $content ='<h1>Wir standen im Weissen Wald ....</h1>';
        $content .='﻿<div class="box full">
                        <div style="margin:0 auto; width: 634px; height:120px;">
                            <!-- "previous page" action -->
                            <!--a class="prev browse left"></a -->

                            <!-- root element for scrollable -->
                            <div id="autoscroll" class="scrollable">
                                <!-- root element for the items -->
                                <div class="items" style="left: -2040px;">
                                    <!-- 1-5 -->
                                    <div>
                                       <img src="'.URL.'public/media/images/snow_1.jpg" alt="" />

                                    </div>
                                    <div>
                                        <img src="'.URL.'public/media/images/snow_2.jpg" alt="" />
                                    </div>
                                    <div>
                                        <img src="'.URL.'public/media/images/snow_3.jpg" alt="" />
                                    </div>
                                    <div>
                                        <img src="'.URL.'public/media/images/snow_4.jpg" alt="" />
                                    </div>
                                    <div>
                                        <img src="'.URL.'public/media/images/snow_5.jpg" alt="" />
                                    </div>
                                    <div>
                                        <img src="'.URL.'public/media/images/snow_6.jpg" alt="" />
                                    </div>
                                </div>

                            </div>
                        </div>
                        <br clear="all">
                    </div>';
        $size = Helper::getJessiVideoSize();
        $content .= '<div class="cacsTxt" style="padding-top: 20px;text-align: center;">';
        $content .= '<iframe width="'.$size['w'].'" height="'.$size['h'].'" src="http://www.youtube.com/embed/a2_VoUu0VwE?rel=0&autoplay=1" frameborder="0" allowfullscreen></iframe>';
        $content .= '</div>';
        return $content;
    }

    public function getRunTimeJessiFooterMsg(){
        return '';
        $size = Helper::getJessiVideoSize();
        return '<iframe width="'.$size['w'].'" height="'.$size['h'].'" src="http://www.youtube.com/embed/a2_VoUu0VwE?rel=0&autoplay=1" frameborder="0" allowfullscreen></iframe>';

    }

}